package sample8month;
import java.io.*;

public class PrimitiveDataStreamFile{
    public static void main(String args[]) throws Exception {

         if(args.length !=1){
	     System.out.println("usage: PrimitiveDataFile filename");	
	     return;
	 }

          FileOutputStream outputFile=new FileOutputStream(args[0]);        
          DataOutputStream outputStream=new DataOutputStream(outputFile);

	  outputStream.writeBoolean(true);
          outputStream.writeChar('A');
          outputStream.writeByte(Byte.MAX_VALUE);
	  outputStream.writeShort(Short.MIN_VALUE);
	  outputStream.writeInt(Integer.MAX_VALUE);
	  outputStream.writeLong(Long.MIN_VALUE);
	  outputStream.writeFloat(Float.MAX_VALUE);
	  outputStream.writeDouble(Math.PI);
    
          outputStream.close();
       
         FileInputStream inputFile=new FileInputStream(args[0]);


	  DataInputStream inputStream=new DataInputStream(inputFile);

         boolean bo=inputStream.readBoolean();
         char c=inputStream.readChar();
         byte by=inputStream.readByte();
	 short s=inputStream.readShort();
	 int i=inputStream.readInt();
	 long l=inputStream.readLong();
	 float f=inputStream.readFloat();
	 double d=inputStream.readDouble();
      


         inputStream.close();
           System.out.println("read");
         
       System.out.println(bo);
	 System.out.println(c);
	 System.out.println(by);
	 System.out.println(s);
	 System.out.println(i);
	 System.out.println(l);
	 System.out.println(f);
	 System.out.println(d); 

      
       }
         
}